package com.cch.cooperation.api.zone.controller;

import com.cch.cooperation.api.auth.dto.LoginUserDTO;
import com.cch.cooperation.api.zone.dto.*;
import com.cch.cooperation.api.zone.service.ZonePostLikeServiceImpl;
import com.cch.cooperation.api.zone.service.ZonePostServiceImpl;
import com.cch.cooperation.common.page.PageList;
import com.cch.cooperation.common.web.response.Response;
import com.cch.cooperation.common.web.session.Session;
import com.cch.cooperation.common.web.session.SessionManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 空间动态点赞接口
 *
 * @author cch
 */
@Api(tags = "空间动态点赞接口")
@RestController
@RequestMapping("/api/zone/post/like")
public class ZonePostLikeController {

    @Resource
    private ZonePostLikeServiceImpl zonePostLikeService;
    @Resource
    private SessionManager sessionManager;

    @ApiOperation("点赞或取消赞")
    @PostMapping ("/trigger")
    public Response<ZonePostLikeDTO> trigger(@RequestBody ZonePostLikeTriggerDTO req) {
        Session<LoginUserDTO> session = sessionManager.get();
        req.setUserId(session.getData().getId());
        ZonePostLikeDTO data = zonePostLikeService.trigger(req);
        return Response.success(data);
    }

}
